package com.bjpowernode.test07;

import java.util.Arrays;

public class Array {
    public static void main(String[] args) {
        //定义一个数组
        int[] array = {4,56,4,6,46,125,34,56,41};
//        System.out.println(getMax(array));
        int[] ver = getRever(array);
        System.out.println(Arrays.toString(ver));


    }
    //定义方法,找出数组中元素最大的索引值
    public static int getMax(int[] array){
        int max = 0;
        for (int i=0;i<array.length;i++){
            if (max<array[i]){
                max = array[i];
            }
        }
        for (int j=0;j<array.length;j++){
            if (max == array[j]){
                return j;
            }
        }
        return 0;
    }

    //将数组中的元素逆序方法
    public static int[] getRever(int[] array){
        int index = 0;
        int[] ver = new int[array.length];
        for (int i=array.length-1;i>=0;i--){
            ver[index] = array[i];
            index ++;
        }
        return ver;
    }

}
